import React, { createRef } from 'react';
import { Button, Radio, Form, Input } from 'antd-mobile'
import url from '../config/url';
import req from "../http/req"
const Form1 = (props) => {
  const formRef = createRef()
  // formRef.current.setFieldsValue({
  //   id: props.fn1().id,
  //   username: props.fn1().username,
  //   password: props.fn1().password,
  //   email: props.fn1().email,
  //   gender: props.fn1().gender,
  //   status: props.fn1().status,
  //   mobile: props.fn1().mobile,
  // })
  const onFinish = (values) => {
    console.log(values);
    req.put(url.EditUserData + `/${values.id}`, {
      username: values.username,
      password: values.password,
      email: values.email,
      status: values.status,
      gender: values.gender,
      mobile: values.mobile,
    }).then(res => {
      console.log(res);
    })
  }
  return (
    <div>
      <Form layout='horizontal' ref={formRef} onFinish={onFinish}>
        <Form.Header>修改用户信息</Form.Header>
        <Form.Item label='序号' name='id'>
          <Input placeholder='请输入' defaultValue={props.fn1().id} />
        </Form.Item>
        <Form.Item label='用户名' name='username'>
          <Input placeholder='请输入' defaultValue={props.fn1().username} />
        </Form.Item>
        <Form.Item label='密码' name='password'>
          <Input placeholder='请输入' defaultValue={props.fn1().password} />
        </Form.Item>
        <Form.Item label='邮箱' name='email'>
          <Input placeholder='请输入' defaultValue={props.fn1().email} />
        </Form.Item>
        <Form.Item
          label="性别"
          name='gender'
        >
          <Radio.Group>
            <Radio value="1"> 男 </Radio>
            <Radio value="2"> 女 </Radio>
            <Radio value="3"> 保密 </Radio>
          </Radio.Group>
        </Form.Item>
        <Form.Item
          label="状态"
          name='status'
        >
          <Radio.Group>
            <Radio value="1"> 正常 </Radio>
            <Radio value="2"> 禁用 </Radio>
          </Radio.Group>
        </Form.Item>
        <Form.Item label='手机号' name='mobile'>
          <Input placeholder='请输入' defaultValue={props.fn1().mobile} />
        </Form.Item>
        <Form.Item >
          <Button type="primary" htmlType="submit">
            确认修改
          </Button>
        </Form.Item>
      </Form>
    </div>
  );
}

export default Form1;
